DRAFT: fix: When NoTLS is set, don't do StartTLS#201
DRAFT: fix: When NoTLS is set, don't do StartTLS#201selfhoster1312 wants to merge 1 commit intoxmppo:masterfrom
Conversation
|
Thank you very much for suggesting a change, but I think this already possible. See the docs for the options for more details:
Best regards |
|
Hello, thanks for replying so quickly. Here's what i did: https://github.com/matterbridge-org/matterbridge/blob/2bb66da51a25c7f1da606adfb3543b8c1cf96897/tests/xmpp/xmpp.go#L112 It was definitely not working without this patch, but it was based on really old go-xmpp (as you are aware). I'll try the same settings on the new version and let you know. |
|
I can confirm it does not work without the patch: https://github.com/matterbridge-org/matterbridge/actions/runs/18786159951/job/53604836999?pr=8 I get on matterbridge side: Here's the prosody debug logs: I'm still not sure this PR is how to properly fix it but i'm sure there's a problem :) :) |
|
Looks this is about the auth mechanism, not about encryption. But that's weird as
I'll need to have a closer look, but I am not sure whether I get something done today. |
|
My understanding is that tlsConnOK evaluates to false, which makes it impossible to select the PLAIN mechanism on go-xmpp side. Don't worry if you don't have time. There are more important things in life than TLS issues :D And anyway this is on a test branch at the moment because i'm starting to use it to test matterbridge with a real prosody server. This has no incidence on matterbridge's main branch which i should be able to update. |
| mechanism = "X-OAUTH2" | ||
| // Do not use PLAIN auth if NoPlain is set. | ||
| case slices.Contains(mechSlice, "PLAIN") && tlsConnOK && !o.NoPLAIN: | ||
| case slices.Contains(mechSlice, "PLAIN") && (tlsConnOK || o.NoTLS) && !o.NoPLAIN: |
There was a problem hiding this comment.
I think from a security point of view we should make it very hard to use PLAIN auth over an unencrypted connection. So maybe better not allow PLAIN here, but set set Mechanism in Options to PLAIN, then the else clause won't be used.
| if f, err = c.startTLSIfRequired(f, o, domain); err != nil { | ||
| return err | ||
| // unless the client has specified NoTLS | ||
| if !o.NoTLS { |
There was a problem hiding this comment.
I am not sure if we should use the directTLS setting to control whether StartTLS is used. I'll check if there is an alternative.
|
I think the |
|
Not responding in the review because there's overlapping points. I think the mental model is something like:
Are we on the same page? |
That looks good! I'll give it a go (though maybe not tonight) |
There is a lot that can be improved, but I am only a little bit working on this library as I am a user of it. So don't expect me to do big reworks. :)
If you check SRV records you might want to be explicit about whether you want to use direct TLS or StartTLS. Also I am reluctant to change the default behavior of options that are in use for a long time.
There is no DisableEncryption, not sure if need as NoTLS, StartTLS and InsecureAllowUnencryptedAuth should be enough options for that. :)
I find it reasonable to disable PLAIN on unencrypted connections and -PLUS variants require encryption so there will be always a relation between mechanisms and encryption.
Mostly I guess. |
Can you show me the error? Somehow this doesn't fully render for me and the output ends at
|
Same errors. It's not visible in the test.sh job, but in the setup.log job (prosody log) and matterbridge.log job. |
Only directTLS should be explicit, because few servers support it. startTLS should be the implied default.
That's a good enough name!
I was using PLAIN on unencrypted connection (localhost). I'm aware some variants require specific settings but i believe this depends on the server implementation so the best thing to do is have good defaults (don't manually set the mechanisms) and let the user configure it as they like for very specific cases such as mine, and deal with server errors if any. I was suggesting to remove the link between those two kinds of settings because it requires more complex conditions handling. I think having proper errors emanating from the underlying libraries or the remote server would be more user-friendly than simply failing because the condition chain is so complex we have a logic bug. What do you think? |
It is, if you set neither StartTLS will be done if supported by the server.
Maybe we disagree about good defaults. Not using PLAIN over an unencrypted connection is a reasonable default for me. For your use case I find it ok, to have to set some extra settings. It's only that there currently is a bug somewhere.
Not sure what link you mean, can you elaborate? |
That's weird, that means mechanism is not set. Can you doublecheck you have set Mechanism to |
|
I set up a local prosody and I was able to connect using the updated branch with the latest commits and these settings: NoTLS = true, Please check if it is also fixed for you. |
I agree :)
I meant my proposed change ( Maybe my brain is not working at the moment. I've rebased my branch on your latest commits, but still nothing… https://github.com/matterbridge-org/matterbridge/actions/runs/18800711155/job/53647792486?pr=8 |
|
I wanted to check your prosody config on my machine but seems there is something missing:
How do you create your test user? |
|
Ok, seems prosody doesn't let me log in. I fixed it by changing It just didn't offer any authentication mechanisms, after creating a user it does: |
|
Maybe you wanted to use this module but failed to install it? |
It was not possible to use plain auth with an unencrypted connection (e.g. for test setups), this is now possible. See #201 for context.
I don't. Any login is considered valid as that makes orchestration easier: The original reason i wanted to try PLAIN auth was to make everything simpler which it's definitely not doing. Also it appears auth_any only supports PLAIN mechanism because the server doesn't know the password beforehand (according to prosody devs). |
That you have to pull some strings to use PLAIN over an unencrypted connection is intentional as it is really dangerous in general. |
After taking a break away from the computer i believe you are right. I'll try something :) |
|
Can you maybe share your go-sendxmpp command? I still can't get it to work: |
|
You'll need the insecure version:
`go install ***@***.***`
And run the command like that:
`fortune|~/go/bin/go-sendxmpp -dj matterbridge-test.localhost:52222 -u ***@***.*** -p test333 --allow-plain ***@***.***`
|
|
Ah, the TLS version is too low. Go-sendxmpp uses TLSv1.3 as default, but
you can downgrade it: `--tls-version 12` will use TLSv1.2
|
|
Yes sorry i was on the wrong branch. I now see i need to specify Mechanism PLAIN even with When i set it manually on the new branch i can indeed connect. Sorry for wasting your neurons :) |
|
On Sat Oct 25, 2025 at 17:46 CEST, selfhoster1312 wrote:
Yes sorry i was on the wrong branch. I now see i need to specify Mechanism PLAIN even with `InsecureAllowUnencryptedAuth`. I believe you already mentioned that but could we maybe automatically add it when InsecureAllowUnencryptedAuth is set?
I need to think about that. It would then fail if a server doesn't offer
PLAIN but only better methods if we pin the mechanism to PLAIN. Maybe
there is a way to differently fix that, let me check.
When i set it manually on the new branch i can indeed connect. Sorry for wasting your neurons :)
No problem, sometimes debugging is like this.
|
|
Ok, I pushed a new commit to go-xmpp and the insecure go-sendxmpp
branch, can you check?
|
|
That's perfect, thank you so much! |
When using prosody in CI i really want to use plaintext connection. Maybe i should just use random certs and bypass verification but that seemed wrong.
This is the PR that got CI running for matterbridge in matterbridge-org/matterbridge#4
However, i'm not sure if it still applies correctly with the recent updates. I'll come back here once i'm sure.
Also, maybe NoTLS is not the correct option for plaintext auth? It's not clear to me what the mental model of all connection options is in this library. We should probably add docs about the specific order in which they are applied and the option combinations required to reach a server with certain settings.